import React, { Component } from "react";
import "./fonts1/iconfont.css";
import "./index.css";
import Allmoney from "./allMoney";
import Data from "./data";
import ListType from "./listType";
import Bscroll from "better-scroll";

import { Provider } from "./context";


class ShopCar extends Component {
    state = {
        data: Data
    }
    change=(data)=>{
        this.setState({data})
    }
    render() {
        let { data } = this.state;
       
        let obj={
            data,
            change:this.change
        }
        return <Provider value={obj}>
            <div className="box">
                <header>
                    <span></span>
                    <span>购物车</span>
                    <span>编辑</span>
                </header>
                <section>
                    <ListType data={data.group} />
                    <Allmoney allFlg={data.allFlg} allPrice={data.allPrice}/>
                </section>
                <footer>
                    <dl>
                        <dt><i className="iconfont icon-shouye"></i></dt>
                        <dd>首页</dd>
                    </dl>
                    <dl>
                        <dt><i className="iconfont icon-gouwuche"></i></dt>
                        <dd>购物车</dd>
                    </dl>
                    <dl>
                        <dt><i className="iconfont icon-wode-xuanzhong"></i></dt>
                        <dd>我的</dd>
                    </dl>
                </footer>
            </div>
        </Provider>
    }
    componentDidMount() {
        new Bscroll(".listType", {
            click: true
        })
    }
}

export default ShopCar;